#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int n, m;
    cin >> n >> m;

    int idx = (1 << n) - 1;	// (2^(n+1) - 1) - (2^n)

    while(m--) {
        int x = 1;
        char ch;
        for(int i = 0; i < n; i++) {
            cin >> ch;
            x *= 2;
            if(ch == 'n')
                x++;
        }
        cout << x - idx << "\n";
    }

    return 0;
}

